<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryRef"
      :inline="true"
      v-show="showSearch"
    >
      <el-form-item label="月份" prop="month">
        <!-- 日期 -->
        <el-date-picker
          v-model="queryParams.month"
          type="month"
          placeholder="请选择月份"
          value-format="YYYY-MM"
        />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <!-- <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          @click="handleExport"
          v-hasPermi="['system:contract:transactionType:add']"
          >导出</el-button
        >
      </el-col>
      <right-toolbar
        v-model:showSearch="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row> -->
    <div>
      <el-row :gutter="10">
        <el-col :span="12" style="margin-bottom: 10px">
          <el-card>
            <template #header>区域成交套数</template>
            <div>
              <el-table :data="dataList" style="width: 100%" border>
                <el-table-column label="区域" prop="regionName" />
                <el-table-column label="区长" prop="regionUserName" />
                <el-table-column label="成交套数" prop="orderNum" />
              </el-table>
            </div>
          </el-card>
        </el-col>
        <el-col :span="12">
          <el-card>
            <template #header>交易类型成交套数</template>
            <div>
              <el-table :data="typeList" style="width: 100%" border>
                <el-table-column label="交易类型" prop="contractTypeName" />
                <el-table-column label="成交套数" prop="orderNum" />
              </el-table>
            </div>
          </el-card>
        </el-col>
      </el-row>
      <el-row :gutter="10">
        <el-col :span="12">
          <el-card>
            <template #header>区域折扣率</template>
            <div>
              <el-table :data="discountList" style="width: 100%" border>
                <el-table-column label="区域" prop="regionName" />
                <el-table-column label="折扣率" prop="agencyFeeRate">
                  <template #default="scope">
                    {{ scope.row.agencyFeeRate }}%
                  </template>
                </el-table-column>
                <el-table-column label="交易费折扣率" prop="dealFeeRate">
                  <template #default="scope">
                    {{ scope.row.dealFeeRate }}%
                  </template>
                </el-table-column>
                <el-table-column label="全佣" prop="fullCommissionRate">
                </el-table-column>
              </el-table>
            </div>
          </el-card>
        </el-col>
      </el-row>
    </div>

    <!-- 添加或修改岗位对话框 -->
    <el-dialog :title="title" v-model="open" width="1000px" append-to-body>
      <div></div>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="OperateReport">
import {
  regionData,
  contractTypeData,
  regionDiscountData,
} from "@/api/mouthNewspaper/endStatistics";
const { proxy } = getCurrentInstance();
import { reactive } from "vue";
const dataList = ref([]);
const open = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const total = ref(0);
const title = ref("");
const data = reactive({
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    month: "",
  },
  rules: {},
});

const { queryParams, rules } = toRefs(data);
const form = ref({});

/** 查询岗位列表 */
function getList() {
  loading.value = true;
  regionData(queryParams.value).then((response) => {
    dataList.value = response.data;
    total.value = response.total;
    loading.value = false;
  });
}
// 交易类型成交套数
const typeList = ref([]);
function getTypeList() {
  loading.value = true;
  contractTypeData(queryParams.value).then((response) => {
    typeList.value = response.data;
    loading.value = false;
  });
}
getTypeList();
//区域折扣率
const discountList = ref([]);
function getDiscountList() {
  loading.value = true;
  regionDiscountData(queryParams.value).then((response) => {
    discountList.value = response.data;
    loading.value = false;
  });
}
getDiscountList();
/** 取消按钮 */
function cancel() {
  open.value = false;
  reset();
}

/** 表单重置 */
function reset() {
  form.value = {};
  proxy.resetForm("postRef");
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  handleQuery();
}

getList();
</script>
<style scoped></style>
